layui.use(['table', 'admin', 'ax', 'func','laydate','form'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;
    var laydate = layui.laydate;
    var form = layui.form;


    /**
     * 管理
     */
    var attendAuditBtyAreaSynchronous = {
        tableId: "attendAuditBtyAreaSynchronousTable"
    };


    /**
     * 获取同步的月份
     *
     *
     */
    attendAuditBtyAreaSynchronous.synchronousMonth = function (data) {
        $.ajax({
            type: "post",
            url: "/attendAuditBtyArea/getSynchronousMonth",
            datatype: "json",
            async: false,
            success: function (data) {
                $("#synchronousMonth").val(data.data.synchronousMonth);
                $("#synchronousMonthSpan").html(data.data.synchronousMonth);
            },
            error: function (data) {
                Feng.error("失败!");
            }
        });
    };

    /**
     * 同步考勤信息
     *
     */
    attendAuditBtyAreaSynchronous.synchronousAttendEmployeeMonth = function (data) {
        
        var queryData = {};
        var attendMonth= $("#month").val();

        queryData['synchronousMonth'] = $("#synchronousMonth").val();
        queryData['notSynchronousshopNum'] = $("#notSynchronousshopNum").val();

        $.ajax({
            type: "post",
            url: "/attendAuditBtyArea/synchronousAttendEmployeeMonth",
            datatype: "json",
            async: false,
            data:queryData,
            success: function (data) {
                if(data.success == true){
                    Feng.success("成功!");
                }else{
                    Feng.error(data.message);
                }
                console.log(data);
                //传给上个页面，刷新table用
                admin.putTempData('formOk', true);
                //关掉对话框
                admin.closeThisDialog();

            },
            error: function (data) {
                Feng.error("失败!");
            }
        });
    }

    // 同步按钮点击事件
    $('#synchronousAttendEmployeeMonth').click(function () {
        if(!$("#notSynchronousshopNum").val()){
            Feng.error("请输入未完成考勤门店");
            return
        }
        attendAuditBtyAreaSynchronous.synchronousAttendEmployeeMonth();
    });








    //初始化页面
    $(function () {
        attendAuditBtyAreaSynchronous.synchronousMonth();
    });

});
